Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added convenience functions for constructing objects from a row #114

Merged
merged 1 commit into from
Feb 13, 2017
Merged

Added convenience functions for constructing objects from a row #114

merged 1 commit into from
Feb 13, 2017

Conversation

dend456
Copy link
Contributor

@dend456 dend456 commented Feb 13, 2017

Added a template function that allows you to retrieve all columns (or first N columns) of a row as an object. Extremely convenient when working with a table that has a large number of columns. Instead of having to do:
int i0 = query.getColumn(0);
int i1 = query.getColumn(1);
...
int i39 = query.getColumn(39);

then passing all those temporary variables into a constructor, you can do:

auto i = query.getColumns<MyClass, 40>();

where MyClass has a constructor that takes 40 arguments that are convertible from a Column object.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.231% when pulling f01a644 on dend456:master into 92bbecc on SRombauts:master.

@SRombauts SRombauts merged commit f69986a into SRombauts:master Feb 13, 2017
@SRombauts
Copy link
Owner

SRombauts commented Feb 13, 2017

Hi @dend456,

Thanks a lot, this is great!

And thanks for providing unit-tests without me asking for it :)

Cheers!

@dend456
Copy link
Contributor Author

dend456 commented Feb 13, 2017

Np, do you think a function that fills a std::vector from all rows in the result would be useful?

@SRombauts
Copy link
Owner

SRombauts commented Feb 13, 2017

Well, it could, but the problem are:

  1. you would like to be able to use any container
  2. I am often using container of unique or shared ptr

(what I mean is that this could lead to a complex template with multiple paramters)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants